/**
 * Copyright (C), 2020, 安徽贝慕信息科技有限公司
 * FileName: AppDetailService
 * Author:   Allen
 * Date:     2020/8/18
 * Description: app配置服务类
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.bim.marvel.openapi.core.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bim.marvel.openapi.core.dao.AppDetailDAO;
import com.bim.marvel.openapi.client.query.AppDetailQuery;
import com.bim.marvel.openapi.core.entity.AppDetailDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.Date;

/**
 * 〈app配置服务类〉
 *
 * @author Allen
 * @date 2020/8/18
 * @since 1.0.0
 */
@Service
public class AppDetailService extends ServiceImpl<AppDetailDAO, AppDetailDO> {

    /**
     * 保存App信息数据(用户提交需审核，故而相关信息保存不返回，提供单独查询接口即可)
     * @param appDetailQuery App信息实体
     * @return 保存状态
     */
    public Boolean saveAppDateil(AppDetailQuery appDetailQuery) {
        AppDetailDO appDetailDO = new AppDetailDO();
        BeanUtils.copyProperties(appDetailQuery, appDetailDO);
        Date nowDateTime = new Date();
        Calendar cal = Calendar.getInstance();
        cal.setTime(nowDateTime);
        //默认一年
        cal.add(Calendar.YEAR, 1);
        appDetailDO.setExpiredDate(cal.getTime());
        return save(appDetailDO);
    }
}
